package com.iqik.rmi.main;

import com.iqik.rmi.intfs.IHelloService;
import com.iqik.rmi.pojo.User;

import java.net.MalformedURLException;
import java.rmi.Naming;
import java.rmi.NotBoundException;
import java.rmi.RemoteException;

public class RMIClient {
    public static void main(String[] args) throws RemoteException, NotBoundException, MalformedURLException {
        // 1.从注册表中获取远程对象，转成接口
        IHelloService service = (IHelloService) Naming.lookup("//127.0.0.1:8100/sayHello");

        // 2.准备参数（传入对象）
        User iqikia = new User("iqikia", 25);
        // 3.调用远程方法
        String s = service.sayHello(iqikia);
        System.out.println(s);
    }
}
